package com.taocore.top.title.service;

import java.io.UnsupportedEncodingException;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.taocore.top.title.domain.DiagnoseResult;

public class LengthChecker implements TitleChecker{

	static Logger _log = Logger.getLogger(LengthChecker.class.getName());
	
	public static final int BYTES_MIN = 40;
	
	@Override
	public DiagnoseResult check(String title) {
		try {
			int len = title.getBytes("GBK").length;
			if (len < BYTES_MIN)
			{
				DiagnoseResult result = new DiagnoseResult();
				result.setMsg("标题太短，未充分利用关键词，不利于搜索。");
				return result;
			}
		} catch (UnsupportedEncodingException e) {
			_log.log(Level.SEVERE, "", e);
		}
		return null;
	}

}
